import { defineStore } from "pinia";

interface stateType {
    count: number
}
const useCountStore = defineStore("count", {
    // 完整的state写法及数据类型定义
    state: (): stateType => {
        return {
            count: 1,
        }
    },
    getters: {
        doubleCount: (state): number => {
            return state.count * 2;
        }
    },
    actions: {
        increment() {
            this.count++
        },
        incrementN(n: number, m: number) {
            this.count += n + m;
        },
        incrementWait() {
            setTimeout(() => {
                this.count++
            }, 2000);
        }
    }

})
export default useCountStore;